package com.learning.spring.bean.factorybean;

import com.learning.spring.bean.factorybean.entity.Address;
import com.learning.spring.bean.factorybean.entity.User;
import org.springframework.beans.factory.FactoryBean;

/**
 * ClassName: UserFactoryBean
 * Description:
 * Date: 2020/8/21 20:31 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class UserFactoryBean implements FactoryBean<User> {
    @Override
    public User getObject() throws Exception {
        Address address = new Address();
        address.setName("上海");

        User user = new User();
        user.setName("sam");
        user.setAge(30);
        user.setAddress(address);
        return user;
    }

    @Override
    public Class<?> getObjectType() {
        return User.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
